A soldier pleaded guilty Wednesday to being an accessory to the rape and murder of a 14-year-old Iraqi girl and the slaying of her family.

Pfc. Bryan Howard, 20, of Fort Campbell, also pleaded guilty to conspiracy to obstruct justice by lying to his superior officers about the attack last year in Mahmoudiya, 20 miles south of Baghdad. It was one of the most shocking atrocities committed by U.S. troops in the Iraq war.

Howard agreed to five years in prison under a plea deal but will not serve more than 27 months if he follows conditions of the agreement, military judge Col. Stephen Henley said.

In a statement to the court, Howard apologized to the military, his family and the victims. He said he regretted not taking action to stop the killings and not telling the truth. "If I could go back, I would not have let it happen in the first place, and I definitely would have told someone," he said.

Howard faced up to 15 years in prison. Under the agreement, his rank will be reduced to private and he will be dishonorably discharged. He will also have to testify against others charged in the case.

Five soldiers were charged in the rape and killing of Abeer Qassim al-Janabi and the killings of her parents and her younger sister. Two of the soldiers previously pleaded guilty and said Howard's role was minimal.

Howard told the judge Wednesday he was left behind at a checkpoint while four other soldiers went to rape the girl. Howard said he overheard the four planning the attack.

Howard said he only started to realize that someone had been killed after the soldiers returned about 10 minutes later. He said the four soldiers were in a "hectic state and hyper."

Howard said he saw blood on one of the soldier's uniforms, but he didn't remember which one.

"I was slowly starting to believe what they had done, that they had committed the crimes, the rape and the murder," Howard said.

Spc. James P. Barker and Sgt. Paul E. Cortez, who have pleaded guilty to rape and murder, have said they took turns raping the girl while Pfc. Steven D. Green shot and killed her mother, father and younger sister. Green then shot Abeer in the head, they said.

Green, who is accused of being the ringleader but was discharged from the military before being charged, will be prosecuted in a federal court in Kentucky. He pleaded not guilty to charges including murder and sexual assault in the March 12, 2006, attack.

Barker said Howard and another soldier charged, Pfc. Jesse V. Spielman, did not participate in the rape and killings, but he said they were at the house when the assault occurred and had come knowing what the others intended to do.

Howard, of Huffman, Texas, was initially described as a lookout for the crime and other soldiers from the 101st Airborne have said he was not directly involved.

Capt. Ryan Rosauer, one of Howard's lawyers, said the defense would have preferred that Howard be allowed to stay in the military and he plans to ask the commanding general for clemency. He said Howard otherwise accepts his sentence.

"We are obviously happy that the deal came through and his story of his involvement came out," Rosauer said.

Barker was sentenced to 90 years in prison and Cortez received 100. Lawyers for Spielman have said he was not involved in the planning of the murders and rape. His court-martial is scheduled for April 2.